package com.ezjie.ielts.task;

import java.util.HashMap;
import java.util.Map;

import android.content.Context;

import com.ezjie.ielts.core.http.HttpAPI;
import com.ezjie.ielts.core.http.HttpRequestCallBack;
import com.ezjie.ielts.core.http.ServerInterfaceDefinition;

public class WordTask {

	private Context context;

	public WordTask(Context context) {
		this.context = context;
	}

	/**
	 * 
	 * @param httpRequestCallBack
	 */
	public void getWordIsUpdate(String time, String type, HttpRequestCallBack httpRequestCallBack) {
		Map<String, String> params = new HashMap<String, String>();
		params.put("time", time);
		params.put("type", type);

		HttpAPI.getInstance(context).doGetRequest(ServerInterfaceDefinition.WORD_NEWS, params, httpRequestCallBack);
	}

	public void getWordHome(String timezone, HttpRequestCallBack httpRequestCallBack) {
		Map<String, String> params = new HashMap<String, String>();
		params.put("timezone", timezone);

		HttpAPI.getInstance(context).doGetRequest(ServerInterfaceDefinition.WORD_HOMEPAGE, params, httpRequestCallBack);
	}

	public void getShaiciWord(String type, HttpRequestCallBack httpRequestCallBack) {
		Map<String, String> params = new HashMap<String, String>();
		params.put("type", type);

		HttpAPI.getInstance(context).doGetRequest(ServerInterfaceDefinition.WORD_CADIDATE, params, httpRequestCallBack);
	}

	public void getStudyingWord(String type, HttpRequestCallBack httpRequestCallBack) {
		Map<String, String> params = new HashMap<String, String>();
		params.put("type", type);

		HttpAPI.getInstance(context).doGetRequest(ServerInterfaceDefinition.WORD_STUDYING, params, httpRequestCallBack);
	}

	public void submitGroup(String wtid, String known_words, String new_words, String timezone,
			HttpRequestCallBack httpRequestCallBack) {
		Map<String, String> params = new HashMap<String, String>();
		params.put("wtid", wtid);
		params.put("known_words", known_words);
		params.put("new_words", new_words);
		params.put("timezone", timezone);

		HttpAPI.getInstance(context).doPostRequest(ServerInterfaceDefinition.WORD_GROUP, params, httpRequestCallBack);
	}

	public void getNextFilterWord(String type, String selected_words, HttpRequestCallBack httpRequestCallBack) {
		Map<String, String> params = new HashMap<String, String>();
		params.put("type", type);
		params.put("selected_words", selected_words);

		HttpAPI.getInstance(context)
				.doPostRequest(ServerInterfaceDefinition.WORD_CADIDATE, params, httpRequestCallBack);
	}

	public void saveProgress(String wgid, String is_pause, String status, String words,
			HttpRequestCallBack httpRequestCallBack) {
		Map<String, String> params = new HashMap<String, String>();
		params.put("wgid", wgid);
		params.put("is_pause", is_pause);
		params.put("status", status);
		params.put("words", words);

		HttpAPI.getInstance(context).doPostRequest(ServerInterfaceDefinition.WORD_GROUPSTATE, params,
				httpRequestCallBack);
	}

	public void getWordGroup(String wgid, String type, HttpRequestCallBack httpRequestCallBack) {
		Map<String, String> params = new HashMap<String, String>();
		params.put("wgid", wgid);
		params.put("type", type);

		HttpAPI.getInstance(context).doGetRequest(ServerInterfaceDefinition.WORD_GROUP, params, httpRequestCallBack);
	}

	public void getReviewGroup(String time, String type, String timezone, HttpRequestCallBack httpRequestCallBack) {
		Map<String, String> params = new HashMap<String, String>();
		params.put("time", time);
		params.put("type", type);
		params.put("timezone", timezone);

		HttpAPI.getInstance(context).doGetRequest(ServerInterfaceDefinition.WORD_AGENDA, params, httpRequestCallBack);
	}
}
